//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using CommunityServer.Components;

namespace CommunityServer.Controls
{
	/// <summary>
	/// Summary description for CheckmarkControl.
	/// </summary>
	public class CheckmarkControl : WebControl {
		public CheckmarkControl() {
			//
			// TODO: Add constructor logic here
			//
		}

		protected override void Render(HtmlTextWriter writer) {
			writer.WriteBeginTag("img");
			// write either the checkmark.gif or the crossmark.gif
			writer.WriteAttribute("src", String.Format("{0}/images/{1}mark.gif", Globals.GetSkinPath() , this.Checked ? "check" : "cross") );
			writer.WriteAttribute("height", "15");
			writer.WriteAttribute("width", "16");

			if( this.RenderTitle )
				writer.WriteAttribute("alt", this.Checked ? ResourceManager.GetString("ForumPermissionAdmin_Allow") : ResourceManager.GetString("ForumPermissionAdmin_Deny"));
			
			writer.WriteEndTag("img");
		}

		[
		Bindable(true),
		Category("Appearance"),
		Description("Gets or sets the value used to indicate a check or cross mark"),
		DefaultValue(false)
		]
		public virtual bool Checked {
			get{ return _checked; }
			set{ _checked = value; }
		}

		[
		Bindable(true),
		Category("Appearance"),
		Description("Gets or sets the value used to control whether the alternate text or legend is written"),
		DefaultValue(false)
		]
		public bool RenderTitle {
			get{ return _renderTitle; }
			set{ _renderTitle = value; }
		}

		private bool _checked		= false;
		private bool _renderTitle	= false;
	}
}
